package cn.nkpro.elcube.docengine.cloud;

/**
 * 锁工具类
 */
public class NkCloudDocEngineSyncHelper {

    private NkCloudDocEngineSyncHelper(){}

    private static final ThreadLocal<Boolean> noLock = new ThreadLocal<>();
    public static void run(Function function){
        try{
            noLock.set(true);
            function.apply();
        }finally {
            noLock.remove();
        }
    }

    public static boolean isSyncUpdate(){
        return noLock.get()!=null && noLock.get();
    }

    @FunctionalInterface
    public interface Function{
        void apply();

    }
}
